package com.itheima.web.request; /**
 * @author Xiao
 * @date 2021/8/30
 */

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
/**
 * Request请求转发
 *      req.getRequestDispatcher("/req6").forward(req,resp);
 * Request对象提供了三个方法：
 *      存储数据：void setAttribute(String name,Object o);
 *      获取值：Object getAttribute(String name);
 *      删除键值对：void removeAttribute(String name);
 */
@WebServlet(name = "RequestDemo08", value = "/req08")
public class RequestDemo08 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("demo08...");
        request.setAttribute("username", "zhangsan");
        request.getRequestDispatcher("/req09").forward(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
